import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import DBuitls;
import User;


@WebServlet("/password")
public class PasswordSerlvet extends HttpServlet{
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String user = req.getParameter("user");
		String pwd = req.getParameter("pwd");
		String pwd2 = req.getParameter("pwd2");
		if (pwd.equals(pwd2)){
			QueryRunner qr = new QueryRunner();
			try {
				qr.update(DBuitls.getConn(), "insert into login values (null,?,?)",user,pwd);
				req.setAttribute("password", "成功");
				req.getRequestDispatcher("login.jsp").forward(req, resp);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		else{
			req.setAttribute("miss","两次密码不相同");
			req.getRequestDispatcher("password.jsp").forward(req, resp);
		}
	}
}
